<!DOCTYPE html>
<html lang="en">
<head>
    <title>医院门诊系统</title>
    <!-- 避免中文乱码 -->
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- 引入 Bootstrap -->
    <script src="https://s3.pstatp.com/cdn/expire-1-M/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
    <!-- 引入 toastr -->
    <script src="../toastr/toastr.js"></script>
    <link rel="stylesheet" href="../toastr/toastr.css">
</head>
<script type="text/javascript">
    toastr.options.positionClass = 'toast-bottom-center';
    $(document).ready(function (){
        //接收医生ID
        // 测试默认 doctor_id 是 101 ,但真实id已经从后台seesion获得
        var d_id = "101";
        $("#submit").click(function (){
            $.ajax({
                url:"addcase",
                type:"post",
                contentType:"application/json;charset=UTF-8",
                dataType:"json",
                data:JSON.stringify({
                    patients_name:$("#patients_name").val(),
                    case_condition:$("#case_condition").val(),
                    doctor_name:"ErrorOnGetName",
                    doctor_id:d_id,
                }),
                success:function (flag){
                    if(flag>0) {
                        $("form input")
                            .not(":button",":reset","hidden","submit")
                            .val("")
                            .removeAttr("checked")
                            .removeAttr("selected");
                        $("#case_condition").val("");
                        toastr.success("插入成功");
                    }
                    else{
                        toastr.error("插入失败");
                    }
                }
            })
        })
    })
</script>
<body>
<nav class="navbar navbar-expand-sm bg-primary navbar-dark">
    <ul class="navbar-nav">
        <li class="nav-item">
            <a class="nav-link" href="/tohome" style="font-size:20px">首页</a>
        </li>
        <li class="nav-item">
            <a class="nav-link" href="tocase" style="font-size:20px">病例库</a>
        </li>
        <li class="nav-item active">
            <a class="nav-link" href="toaddcase" style="font-size:20px">录入病例</a>
        </li>
        <li class="nav-item">
            <a class="nav-link" href="/prescribe/toprescribe" style="font-size:20px">开药记录</a>
        </li>
    </ul>
</nav>
<form class="form-horizontal m-3">
    <div class="form-group">
        <label for="patients_name">病人姓名</label>
        <input type="text" class="form-control " id="patients_name" style="width: 500px">
    </div>
    <div class="form-group">
        <label for="case_condition">病情描述</label>
        <textarea class="form-control" id="case_condition" rows="6" style="width: 500px"></textarea>
    </div>
</form>
<button id="submit" class="btn btn-primary m-3">提交</button>
</body>
</html>